- Save the Current Channel
- Set the Channel to 0x40
Backup MMIO offset 0x3F4
Backup PHYRegisters 0x10, 0x11, 0x7A, 0x6E, 0x7C, 0x9, 0x6B
Backup InternalLookupTable 0x3C00 offsets 0x7, 0x9, 0xA
Backup InternalLookupTable 0x3800 offset 0xB
Backup RadioRegisters 0x17, 0x19, 0x9
Backup InternalLookupTable 0x3000 offset 0x1
Bitwise AND RadioRegister 0x9 with 0xFFBF
Write 0 to RadioRegister 0x1E
Unset bit 0x8000 in the APHY All CRS register (PHYRegister 0x29)
Write 1 to MMIO offset 0x3F4
Bitwise OR PHYRegister 0x10 with 0xC08
MaskSet PHYRegister 0x11 with mask 0xF3F7 and set with 0x408
Read the value of InternalLookupTable 0x3800 offset 0x8 and write it to InternalLookupTable 0x3C00 offset 0x7
Write 1 to InternalLookupTable 0x3C00 offset 0x9
Write 1 to InternalLookupTable 0x3C00 offset 0xA
Write 1 to InternalLookupTable 0x3800 offset 0xB
Write 0xC111 to PHYRegister 0x7A
Write 0x0002 to PHYRegister 0x7C
- If the PHY Revision is 2 or less
Write 0 to PHYRegister 0x6B
Write 0x26 to RadioRegister 0x17
- If the PHY Version is 1
MaskSet the value of InternalLookupTable 0x3000 with mask 0xFFFFFF87 and set with 0x10
- Otherwise
MaskSet the value of InternalLookupTable 0x3000 with mask 0xFFFFFFC3 and set with 0x8
Write 0x60 to RadioRegister 0x19
- Start with a saved Collected TSSI Value of -999999
- Loop over the "Radio Register 1E" table below
- If this is one of the first 5 table elements
Bitwise AND the value of RadioRegister 0x1E with 0xF
- Left shift the table value by 4 and bitwise OR with the result
- Otherwise
Bitwise AND the value of RadioRegister 0x1E with 0xF0
- Bitwise OR the table value with the result
Write the result to RadioRegister 0x1E
- Delay 5 uSecs
- If the Collected TSSI Value is greater than the saved Collected TSSI Value
Save the value of RadioRegister 0x1E (as a signed 16 bit value)
- Save the new Collected TSSI Value
Start (or restart) an array of values of RadioRegister 0x1E, keep two arrays, one for the first 5 table elements and one for the second 5 table elements
- Otherwise, if the Collected TSSI Value is equal to the saved Collected TSSI Value
Read the value of RadioRegister 0x1E and add it to the correct array
- If this is the 5th or 10th table element
Write the saved value of RadioRegister 0x1E to RadioRegister 0x1E
- If this is one of the first 5 table elements
Write 0x91 to RadioRegister 0x19
- If there were no values for the second table elements array
- Add a 0 as the only element
Save the saved RadioRegister 0x1E value (this is the previous loop's final saved RadioRegister 0x1E value referenced below)
- Start with a saved Collected TSSI Value of -999999
- Loop over the first table elements array
- Loop over the second table elements array
- Take the current first table elements array item and bitwise AND with 0xF0
- Take the current second table elements array item and bitwise AND with 0xF
Write the Bitwise OR of the two results above to RadioRegister 0x1E
- Delay 5 uSecs
- If the Collected TSSI Value is greater than the saved Collected TSSI Value
Save the value of RadioRegister 0x1E (as a signed 16 bit value)
- Loop over the second table elements array
If the saved RadioRegister 0x1E value is less than 0
Write the previous loop's final saved RadioRegister 0x1E value to RadioRegister 0x1E
- Otherwise
Write the saved value of RadioRegister 0x1E to RadioRegister 0x1E
Save the value of RadioRegister 0x1E for use in other functions
Restore MMIO offset 0x3F4
Restore PHYRegisters 0x10, 0x11
Restore InternalLookupTable 0x3000 offset 1
Restore RadioRegisters 0x17, 0x19
Restore PHYRegister 0x6B
Restore InternalLookupTable 0x3C00 offsets 0x7, 0x9, 0xA
Restore InternalLookupTable 0x3800 offset 0xB
Restore PHYRegisters 0x7A, 0x6E, 0x7C
- If the PHY Revision is 2 or less
Do a DummyTransmission
Set bit 0x8000 in the APHY All CRS register (PHYRegister 0x29)
Write 0 to PHYRegister 0x6B
Write 0x26 to RadioRegister 0x17
- If the PHY Version is 1 or less
MaskSet the value of InternalLookupTable 0x3000 offset 1 with mask 0xFFFFFF87 and set with 0x58
- Otherwise
MaskSet the value of InternalLookupTable 0x3000 offset 1 with mask 0xFFFFFFC3 and set with 0x2C
- Start with a saved Collected TSSI Value of -999999
- Loop twice
- Start with a Loop Counter Value of 5
- While the saved Collected TSSI Value is lower than the Maximum Collection Value (see below) and the Loop Counter Value is 0 or higher
Write the Abstuf Table value corresponding to the current Loop Counter Value to RadioRegister 0x19
- Loop from -15 to 15
- Read the value of
- If this is the first time through the initial loop
Left shift the absolute value of the inner loop position and bitwise OR the result of that with the value of PHYRegister 0x6B bitwise AND'd with 0xFF
Write the result to PHYRegister 0x6B
- Otherwise (the second time through the initial loop)
Bitwise AND the value of PHYRegister 0x6B with 0xFFFFFF00 and bitwise OR it with the absolute value of the inner loop position
Write the result to PHYRegister 0x6B
- If the Collected TSSI Value is greater than the saved Collected TSSI Value
Save the value of PHYRegister 0x6B (as a signed 16 bit value)
- Save the new Collected TSSI Value
Start (or restart) an array of values of PHYRegister 0x6B, keep two arrays, one for the first time through the initial loop and one for the second
- Otherwise, if the Collected TSSI Value is equal to the saved Collected TSSI Value
Add the current value of PHYRegister 0x6B to the appropriate array
- If the saved Collected TSSI Value is less than the Maximum Collection Value (see below)
- Decrement the Loop counter Value
FIXME I need to check this again, it looks wrong
- Start with a Loop Counter Value of 5 and use the two arrays from the previous loop in the loop below
- While the saved Collected TSSI Value is lower than the Maximum Collection Value (see below) and the Loop Counter Value is 0 or higher
Write the AbsI Table value corresponding to the current Loop Counter Value to RadioRegister 0x19
- If there are no elements in the second array, add 0 as the first element
Backup the saved value of PHYRegister 0x6B (The previously saved value used below)
- Start with a saved Collected TSSI Value of -999999
- If there are any elements in the first array
- Loop over the elements in the first array (limited to 16)
- Loop over the elements in the second array (limited to 16)
- Bitwise AND the current first array value with 0xFFFFFF00
- Bitwise AND the current second array value with 0xFF
Write the bitwise OR of the two values above to PHYRegister 0x6B
- If the Collected TSSI Value is greater than the saved Collected TSSI Value
Save the value of PHYRegister 0x6B
- Save the new Collected TSSI Value
- Loop over the elements in the second array (limited to 16)
- If the Collected TSSI Value is less than the Maximum Collection Value (see below)
- Decrement the Loop Counter Value
- Loop over the elements in the first array (limited to 16)
If we didn't save a new value for the saved value of PHYRegister 0x6B
Use the previously saved value of PHYRegister 0x6B as the saved value of PHYRegister 0x6B
Restore MMIO offset 0x3F4
Restore PHYRegisters 0x10, 0x11
Restore InternalLookupTable 0x3000 offset 1
Restore RadioRegisters 0x17, 0x19
Write the saved value of PHYRegister 0x6B to PHYRegister 0x6A
Restore PHYRegister 0x6B
- Delay 10 uSecs
Restore InternalLookupTable 0x3C00 offsets 0x7, 0x9, 0xA
Restore InternalLookupTable 0x3800 offset 0xB
Restore PHYRegisters 0x7A, 0x6E, 0x7C
- If the PHY Revision is 2 or less
Do a DummyTransmission
Set bit 0x8000 in the APHY All CRS register (PHYRegister 0x29)
Restore RadioRegister 0x9
- Set the channel to the saved current channel
Radio Register 1E Table
Loop Position |
Value |
0 |
0 |
1 |
4 |
2 |
8 |
3 |
9 |
4 |
0xD |
5 |
0 |
6 |
1 |
7 |
5 |
8 |
6 |
9 |
0xA |
Maximum Collection Value
PHY Revision |
Value |
3 or greater |
0xFFFFFFC3 |
Otherwise |
0xFFFFFF06 |
AbsI Table
0x60 |
0x61 |
0x62 |
0x91 |
0x9A |
0x9B |
0x9C |
Abstuf Table
0x20 |
0x60 |
0x61 |
0x62 |
0x91 |
0x92 |
0x93 |
0x94 |
0x9C |